package com.cfeng.order.dao;

import java.util.Calendar;
import java.util.List;

import org.springframework.stereotype.Repository;

import com.cfeng.order.entity.ChatOrder;
import com.jeecms.core.JeeCoreDaoImpl;

@Repository
public class ChatOrderDaoImpl extends JeeCoreDaoImpl<ChatOrder> implements
		ChatOrderDao {

	@SuppressWarnings("unchecked")
	public List<ChatOrder> getList() {
		String hql = "from ChatOrder where dayOfWeek = ?";
		Integer dayInWeek = (getDayOfWeek() - 1) % 7;
		return find(hql, dayInWeek == 0 ? 7 : dayInWeek);
	}

	private Integer getDayOfWeek() {
		return Calendar.getInstance().get(Calendar.DAY_OF_WEEK);
	}

	public static void main(String[] args) {
		Integer dayInWeek = (Calendar.getInstance().get(Calendar.DAY_OF_WEEK) - 1) % 7;
		System.out.println(dayInWeek);
	}
}